# -*- coding:utf-8 -*-

import unittest
from app.keyword.keyword_extract import KeywordExtract
from test.test_base import TestBase
from app.common.config import Config

class KeyWordExtractTestCase(unittest.TestCase, TestBase):
    def setUp(self):
        self.initLog('../../logger.ini')
        self.initMongoDb('../../config.ini')
        config = Config('config.ini')
        print config.get('other', 'stopwordsFilePath')
        self.KeywordExtract = KeywordExtract(config.get('other', 'stopwordsFilePath'))

    # def testExtract(self):
    #     self.KeywordExtract.extract(keywordNum=3)

    def testKeyWordByUrl(self):
        keyword = self.KeywordExtract.keyWordByUrl('http://www.cnblogs.com/onepixel/p/6034307.html')
        print keyword

    def testKeySentence(self):
        keysentences = self.KeywordExtract.keySentencesByUrl('http://www.cnblogs.com/onepixel/p/6034307.html')
        print keysentences
    #
    def testReadContent(self):
        content, title = self.KeywordExtract.readContent('http://www.cnblogs.com/onepixel/p/6034307.html')
        # print content
        print title



if __name__ == '__main__':
    unittest.main()